#ifndef GPIOCONTROL_H
#define GPIOCONTROL_H

#include <QObject>
#include <QDebug>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>

#define SYSFS_GPIO_DIR "/sys/class/gpio"
#define MAX_BUF 64
#define SYSFS_ANALOG_DIR "/sys/devices/platform/omap/tsc/"

enum PIN_DIRECTION{
  INPUT_PIN=0,
  OUTPUT_PIN=1
};

enum PIN_VALUE{
  LOW=0,
  HIGH=1
};

//note pin AIN0 maps to device ain1 ... AIN7 maps to ain8!
enum ANALOGINPUT{
    AIN0=1,
    AIN1=2,
    AIN2=3,
    AIN3=4,
    AIN4=5,
    AIN5=6,
    AIN6=7,
    AIN7=8
};

class GPIOControl
{
public:
  GPIOControl();
  static qint16 exp(qint16 gpio);
  static qint16 unexp(qint16 gpio);
  static qint16 setDirection(qint16 gpio, PIN_DIRECTION outFlag);
  static qint16 setValue(qint16 gpio, PIN_VALUE value);
  static qint16 getValue(qint16 gpio, qint16 *value);
  static qint16 setEdge(qint16 gpio, char *edge);
  static qint16 fdOpen(qint16 gpio);
  static qint16 fdClose(qint16 fd);
};

#endif // GPIOCONTROL_H
